# -*- coding: utf-8 -*-

class TabContainer():
    instances = {}

    def __init__(self):
        self.panels = []
        pass

    def addPanel(self, name):
        index = self.getPanelByName(name)
        if index is not None:
            return index

        self.panels.append(name)
        return len(self.panels) - 1

    def getPanelByName(self, name):
        for i, panel in enumerate(self.panels):
            if panel == name:
                return i

        return None


    def remPanel(self, name):
        index = self.getPanelByName(name)
        if index is not None:
            del self.panels[index]

    @classmethod
    def getInstance(self, name):
        if name not in self.instances:
            self.instances[name] = TabContainer()

        return self.instances[name]